package demo24;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolDemo {
    public static void main(String[] args) {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                0,
                1,
                Long.MAX_VALUE,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(1),
                new ThreadFactory() {
                    @Override
                    public Thread newThread(Runnable r) {
                        return new Thread(r, "yc");
                    }
                },
                new ThreadPoolExecutor.AbortPolicy()
        );
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                System.out.println("你好世界");
            }
        };
        executor.execute(runnable);
    }
}
